# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=libcpuid
pkgver=0.5.1
pkgrel=0
pkgdesc="C library for x86 CPU detection and feature extraction"
url="https://github.com/anrieff/libcpuid"
arch="x86 x86_64"
license="BSD-2-Clause"
makedepends="cmake samurai"
checkdepends="python3"
subpackages="$pkgname-dev $pkgname-tool"
source="https://github.com/anrieff/libcpuid/releases/download/v$pkgver/libcpuid-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$crossopts
	cmake --build build
}

check() {
	ninja -C build test-old
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

tool() {
	pkgdesc="$pkgdesc (CLI tool)"

	amove usr/bin
}

sha512sums="
3b2732efcbe8eac9851f057e6879dd9e3c583e7495d0d4ee70e3c0ed08f3e2f6419377f4a37842b062a2a4ac248c347ac5d7d6d2487ece883b37086cdeb8bd7e  libcpuid-0.5.1.tar.gz
"
